<template>
    <div class="personal">
    <!-- 头部 -->
      <router-link to="/edit_profile">
        <div class="profile">
          <!-- <img
            src="http://img1.imgtn.bdimg.com/it/u=3757784226,1202878475&fm=26&gp=0.jpg"
            alt
          /> -->
          <img :src="userInfo.head_img|joinPath" alt="">
          <div class="profile-center">
            <div class="name">
              <span class="iconfont" 
              :class="{iconxingbienan: userInfo.gender==1, iconxingbienv: userInfo.gender==0  }"></span>{{userInfo.nickname}}
            </div>
            <div class="time">{{ userInfo.create_date }}</div>
          </div>
          <span class="iconfont iconjiantou1"></span>
        </div>
      </router-link>
    <!-- 内容 -->
    <div class="content">
        <van-cell title="我的关注" is-link value="关注的用户" />
        <van-cell title="我的跟帖" is-link value="跟帖/回复" />
        <van-cell title="我的收藏" is-link value="文章/视频" />
        <van-cell title="设置" is-link />
    </div>
    <!-- 退出按钮 sign out -->
    <van-button color="#eb6112" round  block @click="signOutFn">退出</van-button>
    </div>
</template>

<script>
import { user } from "@/api/user.js"
export default {
  data(){
    return {
      userInfo: {}
    }
  },
  created(){
    let id = localStorage.getItem("hm-id-71");
    user(id).then(res=>{
      // console.log(37,res);
      this.userInfo = res.data.data;
    })
  },
  methods: {
    // 退出登录
    signOutFn(){
      // 清除token和用户id
      localStorage.removeItem("hm-token-71");
      localStorage.removeItem("hm-id-71");
      localStorage.removeItem("defaultCategory")
      localStorage.removeItem("categoryList")
      localStorage.removeItem("delCategory")
      // 跳转到登录页面  ,当我们不需要传递给路由页面的时候，可以直接通过下面写法进行页面跳转
      this.$router.push("/login")
    }
  }
};
</script>

<style lang="less" scoped>
// 通常组件库的组件名就是该组件的类名
.van-cell{
    background: #eee;
    border-bottom: 1px solid #ddd;
}
.van-button{
    width: 90%;
    margin: 20px auto;
}
.personal{
    width: 100vw;
    height: 100vh;
    background-color: #eee;
}
a{
    color: #666;
}
.profile {
  display: flex;
  padding: 20px 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px #ddd solid;

  img {
    width: (70 / 360) * 100vw;
    height: (70 / 360) * 100vw;
    border-radius: 50%;
  }

  .profile-center {
    flex: 1;
    padding: 0 10px;
  }

  .name {
    span {
      color: #75b9eb;
    }
  }

  .time {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
  }
}
</style>